class Stack {
	items = []; // 使用数组来存储栈的元素
	// 压栈操作
	push(item) {
		this.items.push(item);
	}
	// 弹出栈顶元素
	pop() {
		return this.items.pop();
	}
	// 返回栈顶元素但不移除
	peek() {
		return this.items[this.items.length - 1];
	}
	// 检查栈是否为空
	isEmpty() {
		return this.items.length === 0;
	}
	// 返回栈中元素的个数
	size() {
		return this.items.length;
	}
	// 清空栈
	clear() {
		this.items = [];
	}
}
/**
 * 转换进制的函数
 * @param {*} revertedNumber 需要被转换的数
 * @param {*} baseNumber 进制 默认二进制
 * @returns 
 */
function revertNumber(revertedNumber, baseNumber = 2) {
	const stack = new Stack();
  const relationStr = '0123456789abcdefg'
	let result = "";
	let number = revertedNumber;
	while (number > 0) {
		const remainNumber = number % baseNumber;
		stack.push(remainNumber);
		number = Math.floor(number / baseNumber);
	}
	while (!stack.isEmpty()) {
    const resultStr = relationStr[stack.pop()]
		result = `${result}${resultStr}`;
	}
	return result;
}

console.log(revertNumber(3001112, 16));
